﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="YY.ascx.cs" Inherits="Controls_YY" %>
<script runat="server">
    protected void ddlYY_DataBinding(object sender, EventArgs e)
    {
        ddlYY.Items.Clear();

        DateTime d = DateTime.Now.AddYears(this.YearPlus);
        string fmt = "{0:yyyy}";

        for (int i = 0; i < 10; i++)
        {
            ListItem it = new ListItem(string.Format(fmt, d), d.Year.ToString());
            ddlYY.Items.Add(it);

            d = d.AddYears(-1);
        }

        if (Optional)
        {
            ddlYY.Items.Insert(0, new ListItem(GetGlobalResourceObject("Form", "ddl.EmptyText").ToString(), string.Empty));
        }

        ddlYY.Text = DateTime.Now.Year.ToString();
    }
</script>
<My:MyDropDownList ID="ddlYY" runat="server" OnDataBinding="ddlYY_DataBinding"></My:MyDropDownList>